from langchain_core.messages import AnyMessage
from langgraph.graph import add_messages
from typing import TypedDict, Dict, Union, List, Annotated
from copilotkit import CopilotKitState # extends MessagesState

class AnaState(CopilotKitState):
    indicator: str ## 指标名称.eg. GMV,审批通过率
    title: str ## 指标分析标题. eg. GMV分析报告 
    analysis_path: Dict[str,] ## 分析路径.eg. 按时间,按地域,按用户类型
    analysis_goal: str ## 分析目标.eg. 发现GMV下降的原因
    proposal: Dict[str, Union[str, bool, Dict[str, Union[str, bool]]]]  # Stores proposed structure before user approval
    outline: dict
    sections: List[dict]  # list of dicts with 'title','content',and 'idx'
    footnotes: str
    sources: Dict[str, Dict[str, Union[str, float]]]
    tool: str
    logs: List[dict]  # list of dicts logs to be sent to frontend with 'message', 'status'



# PROPOSAL_FORMAT = {
#     "sections": {
#         "section1": {  # Key is the name of the item
#             "title": "Title of the item",
#             "description": "Description of section1",
#             "approved": False,
#             # Defines if this goes in the final structure. Set only important parts to True by default
#         }
#     },
# }
